package com.lazy.service.impl;

import com.lazy.dao.BicycleTypeDao;
import com.lazy.entity.BicycleType;
import com.lazy.service.BicycleTypeService;
import com.lazy.utils.RespBean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("bicycleTypeService")
public class BicycleTypeServiceImpl implements BicycleTypeService {
    @Resource
    private BicycleTypeDao bicycleTypeDao;

    @Override
    public RespBean addBicycleType(BicycleType bicycleType) {
        if (bicycleTypeDao.addBicycleType(bicycleType)) {
            return RespBean.success("添加单车类型成功");
        }
        return RespBean.error("添加单车类型失败");
    }

    @Override
    public RespBean getAllBicycleType() {
        List<BicycleType> bicycleTypes = bicycleTypeDao.getAllBicycleType();
        if (bicycleTypes != null) {
            return RespBean.success("获取单车类型成功", bicycleTypes);
        }
        return RespBean.success("获取单车类型失败");
    }

    @Override
    public RespBean deleteBicycleType(Integer id) {
        if (bicycleTypeDao.deleteBicycleType(id)) {
            return RespBean.success("删除单车类型成功");
        }
        return RespBean.success("删除单车类型失败");
    }

    @Override
    public RespBean updateBicycleType(BicycleType bicycleType) {
        if (bicycleTypeDao.updateBicycleType(bicycleType)) {
            return RespBean.success("修改单车类型成功");
        }
        return RespBean.success("修改单车类型失败");
    }
}
